package com.gonsin.gview.model.dynamic.form;

import com.gonsin.gview.model.GFormItemModel;
import com.gonsin.gview.model.data.GTreeDataModel;
import com.gonsin.gview.model.dynamic.data.DynamicTreeData;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@ApiModel("树状下拉框")
@AllArgsConstructor
@NoArgsConstructor
public class DynamicMultiTreeSelector extends DynamicFormItem {

    @ApiModelProperty("tree_selector 表示树状复选框，还有check_box\\file\\radio\\rich_text\\text_input\\tree_check_box\\tree_selector")
    private final String itemType = "multi_tree_selector";

    @ApiModelProperty("是否必选")
    private boolean required = true;

    @ApiModelProperty("查询或者提交表单时，表示  ${keyName}=value")
    private String keyName;

    @ApiModelProperty("显示的名字")
    private String name;

    @ApiModelProperty("判断条件显示，支持js语法，例如   showIf=\"type==1\"")
    private String showIf = "1";

    @ApiModelProperty("数据源")
    private DynamicTreeData treeData;

    @ApiModelProperty("根据情况禁用")
    private String disableIf = "0";

    @ApiModelProperty("当单个表单项被修改时，触发对应的action事件")
    private String onChangeAction;



    public static DynamicMultiTreeSelectorBuilder builder() {
        return new DynamicMultiTreeSelectorBuilder();
    }
    public static final class DynamicMultiTreeSelectorBuilder {
        @ApiModelProperty("是否必选")
        private boolean required = true;

        @ApiModelProperty("查询或者提交表单时，表示  ${keyName}=value")
        private String keyName;

        @ApiModelProperty("显示的名字")
        private String name;

        @ApiModelProperty("判断条件显示，支持js语法，例如   showIf=\"type==1\"")
        private String showIf = "1";

        @ApiModelProperty("数据源")
        private DynamicTreeData treeData;

        @ApiModelProperty("根据情况禁用")
        private String disableIf = "0";

        @ApiModelProperty("当单个表单项被修改时，触发对应的action事件")
        private String onChangeAction;

        private DynamicMultiTreeSelectorBuilder() {
        }

        public DynamicMultiTreeSelectorBuilder required(boolean required) {
            this.required = required;
            return this;
        }

        public DynamicMultiTreeSelectorBuilder keyName(String keyName) {
            this.keyName = keyName;
            return this;
        }

        public DynamicMultiTreeSelectorBuilder name(String name) {
            this.name = name;
            return this;
        }

        public DynamicMultiTreeSelectorBuilder showIf(String showIf) {
            this.showIf = showIf;
            return this;
        }

        public DynamicMultiTreeSelectorBuilder treeData(DynamicTreeData treeData) {
            this.treeData = treeData;
            return this;
        }

        public DynamicMultiTreeSelectorBuilder disableIf(String disableIf) {
            this.disableIf = disableIf;
            return this;
        }

        public DynamicMultiTreeSelectorBuilder onChangeAction(String onChangeAction) {
            this.onChangeAction = onChangeAction;
            return this;
        }

        public DynamicMultiTreeSelector build() {
            DynamicMultiTreeSelector dynamicMultiTreeSelector = new DynamicMultiTreeSelector();
            dynamicMultiTreeSelector.setRequired(required);
            dynamicMultiTreeSelector.setKeyName(keyName);
            dynamicMultiTreeSelector.setName(name);
            dynamicMultiTreeSelector.setShowIf(showIf);
            dynamicMultiTreeSelector.setTreeData(treeData);
            dynamicMultiTreeSelector.setDisableIf(disableIf);
            dynamicMultiTreeSelector.setOnChangeAction(onChangeAction);
            return dynamicMultiTreeSelector;
        }
    }
}
